package com.example.carefree_server.mapper.m_managerMapper;

import com.example.carefree_server.entity.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StudentMapper {

//    查询所有
    @Select("SELECT * FROM student")
    List<Student> getAllStudents();

//   增加学生信息
    @Insert("INSERT INTO student (sid, sname, spassword, gender, dept, sclass, sphone, problem, text) VALUES (#{sid}, #{sname}, #{spassword}, #{gender}, #{dept}, #{sclass}, #{sphone}, #{problem}, #{text1})")
    void insertStudent(Student student);

//  查询详情（根据id）
    @Select("SELECT * FROM student where sid=#{sid}")
    public Student findStudentById(String sid);

//    修改学生信息
    @Update("UPDATE student SET sname = #{sname}, spassword = #{spassword}, gender = #{gender}, dept = #{dept}, " +
        "sclass = #{sclass}, sphone = #{sphone}, problem = #{problem}, text = #{text} WHERE sid = #{sid}")
    void updateStudent(Student student);

//    删除学生信息
    @Delete("DELETE FROM student WHERE sid = #{sid}")
    void deleteStudentById(String sid);
}
